﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    x:Class="ViewSwitchingNavigation.Email.Views.EmailView"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400" >

    <UserControl.Resources>
        <DataTemplate x:Key="EmailTemplate">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>

                <TextBlock Text="{Binding From}" Grid.ColumnSpan="2" FontWeight="Bold" FontSize="13" Margin="5" AutomationProperties.AutomationId="TextBlockFromData"/>

                <TextBlock Text="To: " FontWeight="Bold"
                           Grid.Row="1" Grid.Column="0" Margin="5,0,5,0" AutomationProperties.AutomationId="TextBlockTo"/>
                <TextBlock Text="{Binding To}"                           
                           Grid.Row="1" Grid.Column="1" AutomationProperties.AutomationId="TextBlockToData"/>


                <TextBlock Text="Subject: " FontWeight="Bold"
                           Grid.Row="2" Grid.Column="0" Margin="5,0,5,0" AutomationProperties.AutomationId="TextBlockSubject"/>
                <TextBlock Text="{Binding Subject}"                           
                           Grid.Row="2" Grid.Column="1" AutomationProperties.AutomationId="TextBlockSubjectData"/>

                <Border Grid.Row="3" Grid.ColumnSpan="2" BorderBrush="#FF0F68A6" BorderThickness="2" Margin="5, 10, 5, 0" >
                    <ScrollViewer VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
                              VerticalScrollBarVisibility="Auto">
                        <TextBlock Text="{Binding Text}" Margin="5" TextWrapping="Wrap" AutomationProperties.AutomationId="TextBlockEmailData"/>
                    </ScrollViewer>
                </Border>
            </Grid>
        </DataTemplate>

    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" Background="White">

        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <ContentControl Content="{Binding Email}" ContentTemplate="{StaticResource EmailTemplate}"
                        HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"/>

        <Button Grid.Row="1" Width="60" HorizontalAlignment="Right" Margin="0,5,5,5"
                        Command="{Binding GoBackCommand}" Content="Go Back"/>
    </Grid>
</UserControl>
